// pages/mine/feedback/feedback.js
let timer = null
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    barTitle: '',
    value: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let title = options.title
    this.setData({
      barTitle: title
    })
  },
  submit(e) {
    let value = this.data.value
    let formId = e.detail.formId
    if (value.length == 0) {
      wx.showToast({
        title: '内容不能为空',
        image: '../../images/warn.png',
        duration: 1000
      })
      return false
    }
    app.request("submit_feedback", {
      fdb_content: value,
      formId: formId
    }, true).then((data) => {
      wx.showToast({
        title: data.message,
        duration: 2000
      })
      timer = setTimeout(() => {
        wx.switchTab({
          url: '../../discovery/discovery'
        })
      }, 2000)
    })
    this.setData({
      value: ""
    })

  },
  getTextAreaValue(e) {
    let value = e.detail.value
    this.setData({
      value: value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setNavigationBarTitle({
      title: "意见反馈"
    })
  }

})